//////#include<iostream>
//////#include<iomanip>
//////#include<cmath>
//////using namespace std;
//////class Point
//////{
//////private:
//////    double x, y;
//////public:
//////    friend double Distance(Point& p1, Point& p2);
//////    Point(double _x, double _y)
//////    {
//////        x = _x;
//////        y = _y;
//////    }
//////};
//////double Distance(Point& p1, Point& p2)
//////{
//////    double dis;
//////    dis = sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
//////    return dis;
//////}
//////int main()
//////{
//////    int t;
//////    double x1, x2, y1, y2;
//////    cin >> t;
//////    while (t--)
//////    {
//////        cin >> x1 >> y1 >> x2 >> y2;
//////        Point p1(x1, y1);
//////        Point p2(x2, y2);
//////        cout << fixed << setprecision(0) << Distance(p1, p2) << endl;
//////    }
//////    return 0;
//////}
////
//////#include<iostream>
//////#include<string>
//////using namespace std;
//////class Account
//////{
//////private:
//////	static int count;
//////	static float InterestRate;
//////	string _accno, _accname;
//////	float _balance;
//////public:
//////	Account(string accno, string name, float balance);
//////	~Account();
//////	void Deposit(float amount);
//////	void Withdraw(float amount);
//////	float GetBalance();
//////	void Show();
//////	static int GetCount();
//////	static float GetInterestRate();
//////	static void setcount(int c);
//////	static void setrate(float rate);
//////	friend void Update(Account& a);
//////};
//////int Account::count;
//////float Account::InterestRate;
//////Account::Account(string accno, string name, float balance) :_accno(accno), _accname(name), _balance(balance) {}
//////Account::~Account() {}
//////void Account::Deposit(float amount)
//////{
//////	_balance += amount;
//////}
//////void Account::Withdraw(float amount)
//////{
//////	_balance -= amount;
//////}
//////float Account::GetBalance()
//////{
//////	return _balance;
//////}
//////void Account::Show()
//////{
//////	cout << _accno << ' ' << _accname << ' ';
//////}
//////int Account::GetCount()
//////{
//////	return count;
//////}
//////float Account::GetInterestRate()
//////{
//////	return InterestRate;
//////}
//////void Account::setcount(int c)
//////{
//////	count = c;
//////}
//////void Account::setrate(float rate)
//////{
//////	InterestRate = rate;
//////}
//////void Update(Account& a)
//////{
//////	a._balance += a._balance * a.InterestRate;
//////	cout << ' ' << a._balance << ' ';
//////}
//////int main()
//////{
//////	int n, i;
//////	float rate, balance_sum = 0, balance, amount;
//////	string accno, accname;
//////	cin >> rate;
//////	cin >> n;
//////	Account::setcount(n);
//////	Account::setrate(rate);
//////	Account** p = new Account * [n];
//////	for (i = 0; i < n; i++)
//////	{
//////		cin >> accno >> accname >> balance;
//////		p[i] = new Account(accno, accname, balance);
//////		p[i]->Show();
//////		cin >> amount;
//////		p[i]->Deposit(amount);
//////		cout << p[i]->GetBalance();
//////		Update(*p[i]);
//////		cin >> amount;
//////		p[i]->Withdraw(amount);
//////		cout << p[i]->GetBalance() << endl;
//////		balance_sum += p[i]->GetBalance();
//////	}
//////	cout << balance_sum;
//////	if (p)
//////	{
//////		for (i = 0; i < n; i++)
//////			delete p[i];
//////		delete[] p;
//////	}
//////}
////
////
////
////#include<iostream>
////using namespace std;
////class Complex
////{
////private:
////	double real;
////	double imag;
////public:
////	Complex();
////	Complex(double r1, double i) 
////	{
////		real = r1;
////		imag = i;
////	}
////	friend Complex add(Complex& c1, Complex& c2);
////	friend Complex minusCom(Complex& c1, Complex& c2);
////	friend void out(const Complex& c);
////};
////Complex add(Complex& c1, Complex& c2)
////{
////	c1.imag += c2.imag;
////	c1.real += c2.real;
////	return c1;
////}
////Complex minusCom(Complex& c1, Complex& c2)
////{
////	c1.imag -= c2.imag;
////	c1.real -= c2.real;
////	return c1;
////}
////void out(const Complex& c)
////{
////	cout << "(" << c.real << "," << c.imag << ")" << endl;
////}
////int main()
////{
////	int t, r1, l1, r2, l2;
////	char ch;
////	cin >> r1 >> l1;
////	Complex c(r1, l1);
////	cin >> t;
////	while (t--)
////	{
////		cin >> ch >> r2 >> l2;
////		if (ch == '+')
////		{
////			Complex c1(r2, l2);
////			add(c, c1);
////			out(c);
////		}
////		else if (ch == '-')
////		{
////			Complex c1(r2, l2);
////			minusCom(c, c1);
////			out(c);
////		}
////	}
////
////	return 0;
////}
//
//
//#include<iostream>
//#include<string.h>
//#include<iomanip>
//using namespace std;
//class Hotel 
//{
//private:
//	static int num;
//	static	float earn;
//	static float rent;
//	char* _name;
//	int _id;		
//public:
//	Hotel(char* a_Customer) 
//	{
//		_name = new char[strlen(a_Customer) + 1];
//		strcpy(_name, a_Customer);
//		num++;
//		_id = num;
//		earn = num * rent;
//	}
//	~Hotel() 
//	{
//		delete _name;
//	}
//	static void setRent(float r)
//	{
//		rent = r;
//	}
//	void Display() 
//	{
//		cout << _name << " 2015" << setfill('0') << setw(4) << _id;
//		cout << " " << _id << " " << earn << endl;
//	}
//};
//float Hotel::rent = 0;
//int Hotel::num = 0;
//float Hotel::earn = 0;
//int main() 
//{
//	float rent;
//	char name[50];
//	cin >> rent;
//	Hotel::setRent(rent);
//	while (1) 
//	{
//		cin >> name;
//		if (name[0] == '0')
//			break;
//		Hotel h1(name);
//		h1.Display();
//	}
//}

#include<iostream>
#include<iomanip>
using namespace std;
class CDate;
class CTime
{
private:
	int hour, min, sec;
public:
	friend void Display(CDate&, CTime&);
	void input()
	{
		cin >> hour >> min >> sec;
	}
};
class CDate
{
private:
	int year, month, day;
public:
	friend void Display(CDate&, CTime&);
	void input()
	{
		cin >> year >> month >> day;
	}
};
void Display(CDate& date, CTime& time)
{
	cout << date.year << '-' << setfill('0') << setw(2) << date.month << '-' 
		<< setw(2) << date.day << ' '
		<< setw(2) << time.hour << ':' 
		<< setw(2) << time.min << ':' 
		<< setw(2) << time.sec << endl;

}
int main()
{
	int t;
	CDate date;
	CTime time;
	cin >> t;
	while (t--)
	{
		date.input();
		time.input();
		Display(date, time);
	}
}